package com.hg.helix.laboratory.demo.core;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonIgnore;

import lombok.Data;

/**
 * 返回消息体
 * 
 * @author zhaowei
 *
 * @param <T>
 */
@Data
public class Result<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 成功标志
	 */
	private boolean success = true;

	/**
	 * 返回处理消息
	 */
	private String message = "";

	/**
	 * 返回代码
	 */
	private Integer code = 0;

	/**
	 * 返回数据对象 data
	 */
	private T result;

	public Result() {
	}

	public static <T> Result<T> success(String message, T data) {
		Result<T> r = new Result<T>();
		r.setSuccess(true);
		r.setCode(0);
		r.setMessage(message);
		r.setResult(data);
		return r;
	}
	
	public static <T> Result<T> success(String message) {
		Result<T> r = new Result<T>();
		r.setSuccess(true);
		r.setCode(0);
		r.setMessage(message);
		return r;
	}

	@JsonIgnore
	private String onlTable;
}
